package com.dy.design_pattern_study.state_pattern.dome3.impl;

import com.dy.design_pattern_study.state_pattern.dome3.State;
import com.dy.design_pattern_study.state_pattern.dome3.entry.Work;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-06
 * @Content 晚上状态
 */
public class EveningState extends State {
    @Override
    public void writeProgram(Work work) {
        if (work.isFinish()) {
            work.setState(new RestState());
            work.writeProgram();
        }else {
            if (work.getHour() < 20) {

                System.out.println("晚上加班中，当前时间 = " + work.getHour());

            } else {
                //超过 20 点，就进入 强制下班状态
                work.setState(new ForcedOffDutyState());
                work.writeProgram();
            }
        }
    }
}
